#ifndef GAME163_H_
#define GAME163_H_
#include <unordered_set>
int longestUnique(char *c, int b, int e) {
	std::unordered_set<char> set;
	int r = 0, max = 0;
	for (int i = b; i < e; i++) {
		if (set.find(c[i]) != set.end()) {
			if (r > max)
				max = r;
			r = 1;
			set.clear();
		}
		else {
			r++;
			set.insert(c[i]);
		}
	}
	if (r > max)
		max = r;
	return max;
}

void calProduct(int *a, int *b, int n) {
	b[1] = a[0];
	for (int i = 2; i < n; i++) {
		b[i] = b[i - 1] * a[i - 1];
	}
	b[0] = a[n-1];
	for (int i = n - 2; i >= 1; i--) {
		b[i] *= b[0];
		b[0] *= a[i];
	}
}

int longesUnique2(char *ca, int b, int e) {
	bool table[26];
	int r = 0, current = 0;
	memset(table, 0, sizeof(table));
	for (int i = b; i < e; i++) {
		if (table[ca[i] - 'a']) {
			if (current > r) {
				r = current;
			}
			current = 1;
			memset(table, 0, sizeof(table));
		}
		else {
			table[ca[i] - 'a'] = true;
			current++;
		}
	}
	if (current > r)
		r = current;
	return r;
}

#endif